#include "DFont.h"

DFont::DFont(void)
{
}

DFont::~DFont(void)
{
}

bool DFont::init()
{
	D3DXFONT_DESC desc;
	desc.CharSet = HANGUL_CHARSET;
	_tcscpy_s(desc.FaceName,32,_T(""));
	desc.Height = 20;
	desc.Width = 0;
	desc.Weight = FW_NORMAL;
	desc.Quality = DEFAULT_QUALITY;
	desc.MipLevels = 1;
	desc.Italic = 0;
	desc.OutputPrecision = OUT_DEFAULT_PRECIS;
	desc.PitchAndFamily = FF_DONTCARE;

	DDevice* pDevice = DDevice::GetInstance();
	D3DXCreateFontIndirect(pDevice->GetDevice(),&desc,&m_pDXFont);

	

	return true;
}

void DFont::DrawText( int x, int y, D3DXCOLOR color, TCHAR* text, ... )
{
	static RECT rect = { 0,0,0,0 };
	static TCHAR textBuffer[4096] = {0};
	rect.left	= x;
	rect.top	= y;
	
	va_list arg;
	va_start(arg,text);
	_vstprintf_s(textBuffer,4096,text,arg);
	va_end(arg);

	m_pDXFont->DrawTextW(NULL,textBuffer,-1,&rect,DT_NOCLIP,color);

}

bool DFont::Release()
{
	m_pDXFont->Release();
	return true;
}
